FROM arm64v8/golang AS base
ENV GOPATH=/go
ENV GOPROXY=https://goproxy.cn
RUN mkdir -p /go/src/kyland.com/eagle
WORKDIR /go/src/kyland.com/eagle
COPY . .
RUN rm go.mod go.sum && go mod init && go mod tidy

RUN go build -v -o /bin/eagle kyland.com/eagle

FROM arm64v8/ubuntu:22.04 AS server

WORKDIR /
#RUN apt update && apt  install curl telnet lsof iproute2 -y
COPY --from=base /go/src/kyland.com/eagle/tini /
COPY --from=base /bin/eagle /
COPY --from=base /go/src/kyland.com/eagle/etc/config.yml /etc/config.yml
COPY --from=base /go/src/kyland.com/eagle/etc/log.xml    /etc/log.xml
RUN chmod +x /tini /eagle
ENTRYPOINT ["/tini", "--"]

# Run your program under Tini
CMD ["/eagle"]

